<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><< title >></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="<< url_for('static', filename='layui/css/layui.css',t='1483944306685') >>" media="all">
  <link rel="stylesheet" href="<< url_for('static', filename='layui/css/notice.css',t='879425') >>" media="all">
    <link rel="stylesheet" href="<< url_for('static', filename='layui/css/notice.css',t='879425') >>" media="all">
</head>
<body>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"
     style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">字段类型</label>
        <div class="layui-input-block">
            << form.type >>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字段名</label>
        <div class="layui-input-block">
            << form.key(value='aboutme_') >>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字段描述</label>
        <div class="layui-input-block">
            << form.content >>
        </div>
    </div>
    << form.csrf_token >>
      <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
  </div>
<script src="<< url_for('static', filename='layui/layui.all.js',t='1483944306685') >>" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript" src="<< url_for('static', filename='ueditor/ueditor.config.js',t='4399') >>"></script>
<script type="text/javascript" src="<< url_for('static', filename='ueditor/ueditor.all.min.js',t='4399') >>"></script>
<script>
    var $ = layui.jquery, i = layui.view,
            element = layui.element, laydate = layui.laydate,layedit = layui.layedit,
            layer = layui.layer, table = layui.table, form = layui.form,upload=layui.upload;
    //执行实例
    var uploadInst = upload.render({
      elem: '#imgSrc_upload' //绑定元素
      ,url: "<< url_for('main.upload') >>?action=uploadimage" //上传接口
      ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
        layer.load(); //上传loading
      }
      ,acceptMime: 'image/*'
      ,accept:'images'
      ,progress: function(n, elem){
        var percent = n + '%';//获取进度百分比
        element.progress('demo', percent); //可配合 layui 进度条元素使用
      }
      ,done: function(res){
        if(res.status==1){
          $('#imgSrc').val(res.data.src);
          layer.closeAll('loading'); //关闭loading
        }
        else{
          layer.msg(res.msg);
        }
      }
      ,error: function(index, upload){
        layer.msg('网络异常');
        layer.closeAll('loading'); //关闭loading
      }
    });

          //监听提交
    form.on('submit(layuiadmin-app-form-submit)', function(data){
      var field = data.field; //获取提交的字段
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
      //提交 Ajax 成功后，关闭当前弹层并重载表格
      $.ajax({
          url:"<< url_for('admin.ModelAdd') >>",
          type:'post',
          data:field,
          dataType: 'json',
          success: function (returnData) {
                if (returnData.status == 1) {
                    layer.msg('发布成功');
                    parent.location.reload();
                }
                else {
                    layer.msg(returnData.msg)
                }
           }
      });
    });
  </script>
</body>
</html>